<?php

/**
 * @author Terry & 千里孤坟
 * @copyright 2009
 */

class AtkAfterStatus {
	public function __construct(){
		$this->id = -1;
		$this->on = 0;		//开关
		$this->name = "基类";
		$this->time = 0;	//持续回合数，99即作为永久
		$this->n = 0;		//当前进行次数
	}

        public function checkex($a) {
                if(isset($this->excid) && in_array($a->cid,$this->excid)) {
                        $this->name = "<font color=blue>EX".$this->name."</font>";
                        $this->ex = 1;
                        $this->exskset();
                }   
        }

        public function exskset() {
                return 1;
        }  
	
	public function action($a,$sk) {
		return 0;
	}
	
	public function cancel($a) {
		$a->atkafter_status[$this->id]->on = 0;
		$a->atkafter_status[$this->id]->n = 0;
	}
}

class BeastEye extends AtkAfterStatus {
	public function __construct(){
		$this->id = 1;
		$this->on = 0;		//开关
		$this->name = "獣の眼光";
		$this->time = 0;	//持续回合数，99即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
		$this->v = 12;
		$this->excid = array(53);
	}
	
	public function exskset() {
		$this->v = 15;
	}	

	public function action($a) {
		$this->checkex($a);
		if($a->hp >= 0) {
			if($a->agained == 1) return 0;
			$tmp = mt_rand(1,100);
			if($this->v >= $tmp) {
				$a->done = ($a->isboss == 1) ? $a->done : ($a->done - 1);
				$a->agained = 1;
				$a->eyed = 1;
				$a->ap = CalHelper::apointchange($a->ap,2);
				$_SESSION['show'] .= $a->name."獣の眼光发动，再次行动！<br>";
			} else {
				$_SESSION['show'] .= $a->name."獣の眼光发动失败。<br>";
			}
			$_SESSION['result'] .= "獣の眼光发动乱数：".$tmp."<br>";			
		}		
		return 0;
	}
}

class DragonEye extends AtkAfterStatus {
	public function __construct(){
		$this->id = 2;
		$this->on = 0;		//开关
		$this->name = "龍の眼光";
		$this->time = 0;	//持续回合数，99即作为永久
		$this->n = 0;		//当前进行次数
		$this->permanent = 1;	//持久效果
		$this->v = 15;
		$this->excid = array(135);
	}
	
	public function exskset() {
		$this->v = 17;
	}	

	public function action($a) {
		$this->checkex($a);
		if($a->hp >= 0) {
			if($a->agained == 1) return 0;
			$tmp = mt_rand(1,100);
			if(15 >= $tmp) {
				$a->done = ($a->isboss == 1) ? $a->done : ($a->done - 1);
				$a->agained = 1;
				$a->eyed = 1;
				$a->ap = CalHelper::apointchange($a->ap,2);
				if($a->cid == 135) {
					$_SESSION['show'] .= "倘若能赐予伤痕累累的身体以奇迹之力，就请将此灵魂燃烬！<br>";
					CalHelper::cgdisplay("eking_deye.jpg");
				} elseif($a->cid == 62) {
					$_SESSION['show'] .= "味道不错!再来一个!<br>";
					CalHelper::cgdisplay('fengzi_de.jpg');
				}
				$_SESSION['show'] .= $a->name."龍の眼光发动，再次行动！<br>";
			} else {
				$_SESSION['show'] .= $a->name."龍の眼光发动失败。<br>";
			}
			$_SESSION['result'] .= "龍の眼光发动乱数：".$tmp."<br>";			
		}		
		return 0;
	}
}

class CharmAfter extends AtkAfterStatus {

	public function __construct(){
		$this->id = 3;
		$this->on = 0;		//开关
		$this->name = "魅惑";
		$this->time = 0;	//持续回合数，99即作为永久
		$this->n = 0;		//当前进行次数
	}
	
	public function action($a,$sk) {
		if(SkillHelper::isaskill($sk) == 1) {
			list($who,$pos) = $this->charmer;
			$charmer = $_SESSION[$who][$pos];
			if($charmer->hp <= 0) return 0;
			if(CalHelper::ifgroupskill($charmer) == 3) {
				$_SESSION['show'] .= $charmer->name."发动女神の恩寵，完全吸收魅惑反馈AP。<br>";
				$absorbap = $sk->ap;
			} else {
				$absorbap = floor($sk->ap/2);
			}
			CalHelper::apointchange_2($_SESSION[$who][$pos],$absorbap);
			$_SESSION['show'] .= $a->name."本次行动耗费的${absorbap}AP被".$charmer->name."吸收<br>";
		}
		return 0;
	}
	
	public function cancel($a) {
		$a->atkafter_status[$this->id]->on = 0;
		$a->atkafter_status[$this->id]->n = 0;
		unset($a->atkafter_status[$this->id]->charmer);
	}
}

class HellStayer extends AtkAfterStatus {
	public function __construct(){
		$this->id = 4;
		$this->on = 0;		//开关
		$this->name = "異界の住人";
		$this->time = 0;	//持续回合数，99即作为永久
		$this->n = 0;		//当前进行次数
	}
	
	public function action($a) {
		if($a->hp >= 0 && $a->done == 1) {
			$a->hp = 0;
			$_SESSION['show'] .= $a->name."的灵魂遁回了异界<br>";
			CalHelper::disillusion($a);
			$this->cancel($a);
			$a->atkskill_status[52]->cancel($a);
		}
		return 0;
	}
}

class NormalVF extends AtkAfterStatus {
	public function __construct(){
		$this->id = 5;
		$this->on = 0;		//开关
		$this->name = "勝利の戦火";
		$this->time = 0;	//持续回合数，99即作为永久
		$this->n = 0;		//当前进行次数
	}
	
	public function action($a) {
		if($a->hp >= 0) {
			if($a->agained == 1) return 0;
			$tmp = mt_rand(1,100);
			if(20 >= $tmp) {
				$a->done --;
				$a->agained = 1;
				$a->eyed = 1;
				$_SESSION['show'] .= $a->name.$this->name."发动，再次行动！<br>";
			}
			$_SESSION['result'] .= $this->name."发动乱数：".$tmp."<br>";			
		}		
		return 0;
	}
}

class Uragiri extends AtkAfterStatus {
	public function __construct(){
		$this->id = 6;
		$this->on = 0;		//开关
		$this->name = "洗脑";
		$this->time = 2;	//持续回合数，99即作为永久
		$this->n = 0;		//当前进行次数		
		$this->fp = -1;		//原组下标
		$this->tp = -1;		//新组下标
	}
	
	public function action($a) {
		$this->n++;	
		if($this->n < $this->time)	{
			$s .= $a->name."洗脑".$this->n."回合。<br>";
		}
		else {
			$s = $a->name."回过神来了。<br>";
			$this->cancel($a);
		}
		
		$_SESSION['show'] .= $s;
		
		return 0;
	}
	
	public function cancel($a) {
		$a->talked = 0;
		//移回原数组
		if(in_array($a,$_SESSION['a'])) {
			$t = &$_SESSION['a'];
			$f = &$_SESSION['b'];							
		}
		else {
			$t = &$_SESSION['b'];
			$f = &$_SESSION['a'];				
		}
						
		$dummy = new Char;
		$dummy->hp = 0;
		$dummy->name = "占位";
		$dummy->isdummy = 1;
		$f[$this->fp] = $a;
		$t[$this->tp] = $dummy;
	
		 		
		$this->on = 0;
		$this->n = 0;		
		$this->fp = -1;
		$this->tp = -1;
	}
}

class TeaseTurn extends AtkAfterStatus {
	
	public function __construct(){
		$this->id = 7;
		$this->on = 0;		//开关
		$this->name = "被恶戏";
		$this->time = 3;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
	}
	
	public function action($a) {
		$this->n++;	
		if($this->n < $this->time) {
			$s .= $a->name."恶戏状态第".$this->n."回合经过。<br>";
		}
		else {
			$s = $a->name."心态平静下来了，恶戏状态结束<br>";
			$this->cancel($a);
		}
		
		$_SESSION['show'] .= $s;
		
		return 0;
	}
	
	public function cancel($a) {
		$a->vit=$a->initvit;
		unset($a->initvit);
		$a->atkafter_status[$this->id]->on = 0;
		$a->atkafter_status[$this->id]->n = 0;
		$a->before_status[40]->cancel($a);
	}
}

class BeCharmed extends AtkAfterStatus {

	public function __construct(){
		$this->id = 8;
		$this->on = 0;		//开关
		$this->name = "被诱惑";
		$this->time = 3;	//持续回合数，99即作为永久
		$this->n = 0;		//当前进行次数		
		$this->fp = -1;		//原组下标
		$this->tp = -1;		//新组下标
	}
	
	public function action($a) {
		$this->n++;	
		if($this->n < $this->time) {
			$s .= $a->name.$this->name."第".$this->n."回合经过。<br>";
		}
		else {
			$s = $a->name."的意志恢复了。<br>";
			$this->cancel($a);
		}
		
		$_SESSION['show'] .= $s;
		
		return 0;
	}
	
	public function cancel($a) {
		$a->talked = 0;
		//力魔上升状态恢复
		if($a->before_status[3]->on == 1) $a->before_status[3]->cancel($a);
		if($a->before_status[5]->on == 1) $a->before_status[5]->cancel($a);
		//移回原数组
		if(in_array($a,$_SESSION['a'])) {
			$t = &$_SESSION['a'];
			$f = &$_SESSION['b'];							
		}
		else {
			$t = &$_SESSION['b'];
			$f = &$_SESSION['a'];				
		}
						
		$dummy = new Char;
		$dummy->hp = 0;
		$dummy->name = "占位";
		$dummy->isdummy = 1;
		$f[$this->fp] = $a;
		$t[$this->tp] = $dummy;
		$this->on = 0;
		$this->n = 0;		
		$this->fp = -1;
		$this->tp = -1;
	}

}

class BeCrawled extends AtkAfterStatus {

	public function __construct(){
		$this->id = 9;
		$this->on = 0;		//开关
		$this->name = "英雄狩り";
		$this->time = 3;	//持续回合数，99即作为永久
		$this->n = 0;		//当前进行次数		
		$this->fp = -1;		//原组下标
		$this->tp = -1;		//新组下标
	}
	
	public function action($a) {
		$this->n++;	
		if($this->n < $this->time) {
			$s .= $a->name.$this->name."第".$this->n."回合经过。<br>";
		}
		else {
			$s = $a->name."终于在共事中逐渐认清了某人的淫荡本质，回到了自己的阵营。<br>";
			$this->cancel($a);
		}
		
		$_SESSION['show'] .= $s;
		
		return 0;
	}
	
	public function cancel($a) {
		$a->talked = 0;
		//移回原数组
		if(in_array($a,$_SESSION['a'])) {
			$t = &$_SESSION['a'];
			$f = &$_SESSION['b'];							
		}
		else {
			$t = &$_SESSION['b'];
			$f = &$_SESSION['a'];				
		}
						
		$dummy = new Char;
		$dummy->hp = 0;
		$dummy->name = "占位";
		$dummy->isdummy = 1;
		$f[$this->fp] = $a;
		$t[$this->tp] = $dummy;
		$this->on = 0;
		$this->n = 0;		
		$this->fp = -1;
		$this->tp = -1;
	}

}

class BeCharmedInDuel extends AtkAfterStatus {

	public function __construct(){
		$this->id = 10;
		$this->on = 0;		//开关
		$this->name = "停止行动";
		$this->time = 3;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
	}
	
	public function action($a) {
		$this->n++;	
		if($this->n < $this->time)	{
			$_SESSION['show'] .= $a->name.$this->name."状态中。第".$this->n."回合。<br>";
		} else {
			$_SESSION['show'] .= $a->name."从".$this->name."中恢复过来。<br>";
			$this->cancel($a);
		}
		return 0;
	}

	public function cancel($a) {
		$a->atkafter_status[$this->id]->on = 0;
		$a->atkafter_status[$this->id]->n = 0;
		$a->before_status[41]->cancel($a);
	}
}

class BossAgain extends AtkAfterStatus {

	public function __construct(){
		$this->id = 11;
		$this->on = 0;		//开关
		$this->name = "BOSS再动";
		$this->time = 0;	//持续回合数，99即作为永久
		$this->n = 0;		//当前进行次数
	}
	
	public function action($a) {
		if($a->hp >= 0) {
			if($a->eyed == 1) {
				$a->eyed = 0;
			} else {
				$this->n++;
			}
			$_SESSION['show'] .= $a->name."总共".$this->time."次行动，第".$this->n."次完成<br>";
			if($this->n < $this->time) {
				$a->done --;
			} else {
				$this->n = 0;
				$a->agained = 1;
			}
		}
		return 0;
	}

	public function cancel($a) {
		return 0;
	}
}

class DClaim extends AtkAfterStatus {

	public function __construct(){
		$this->id = 12;
		$this->on = 0;		//开关
		$this->name = "死亡告知";
		$this->time = 5;	//持续回合数，99即作为永久
		$this->n = 0;		//当前进行次数
	}
	
	public function action($a) {
		if($a->hp <= 0) return 0;
		$this->n++;
		if($this->n < $this->time) {
			$s .= $a->name.$this->name."第".$this->n."回合经过。<br>";
		}
		else {
			$a->hp = 0;
			$a->bomded = 1;	//无视不屈硬食
			$_SESSION['show'] .= $a->name."的肉体突然僵硬了，断了气的身躯直挺挺地仆倒在地上。<br>";
		}
		return 0;
	}

	public function cancel($a) {
		$a->atkafter_status[$this->id]->on = 0;
		$a->atkafter_status[$this->id]->n = 0;
	}
}
?>
